﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.UI.WebControls;
using System.Web.UI;


namespace DVSProject
{
    public class PopupHelperWeb
    {
        public PopupHelperWeb()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public static void ShowConfirmMessage(Page Page, string strConfirm, string UrlToGoAfferMessage)
        {
            string str = "<script language=javascript>return confirm('" + strConfirm + "');";
            if (UrlToGoAfferMessage != "")
            {
                str = str + "location.replace('" + UrlToGoAfferMessage + "')";
            }
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }

        public static string ShowConfirmMessage(string strConfirm)
        {
            string str = "return confirm('" + strConfirm + "');";
            return str;
        }

        public static void ShowMessage(Page Page, string message, string UrlToGoAfferMessage)
        {
            string str = "<script language=javascript>alert('" + message + "');";
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }

        public static string ShowMessage(string message)
        {
            string str = "alert('" + message + "');";
            return str;
        }

        public static string OpenForm(string Url)
        {
            string str = "window.open('" + Url + "',null,' height=1024, width= 768, status=no, resizable= 1, scrollbars= 1, toolbar= no,location= 1, menubar= no');";
            return str;
        }

        public static string OpenFormHindMenuBar(string Url)
        {
            string str = "window.open('" + Url + "',null,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');";
            return str;
        }
        public static string OpenFormHindMenuBar_AddTest(string Url)
        {
            string str = "window.open('" + Url + "',null,' height=600px, width= 968px,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');";
            return str;
        }


        public static string ShowMessage(string message, string UrlToGoAfferMessage)
        {
            string str = "alert('" + message + "');";
            str = str + "location.href('" + UrlToGoAfferMessage + "');";
            return str;
        }

        public static void ShowMessageAndClose(Page Page, string message, string UrlToGoAfferMessage)
        {
            string str = "<script language=javascript>alert('" + message + "');";
            str = str + "window.close();";
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }

        public static void ShowMessageAndGotoPreviousPage(Page Page, string message, string UrlToGoAfferMessage)
        {
            string str = "<script language=javascript>alert('" + message + "');";
            str = str + "history.back();";
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }

        public static void ShowMessageAndRedirect(Page Page, string message, string UrlToGoAfferMessage)
        {
            string str = "<script language=javascript>alert('" + message + "');";
            str = str + "location.href('" + UrlToGoAfferMessage + "');";
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }
        public static string ShowMessageAndRedirect(string message, string UrlToGoAfferMessage)
        {
            string str = "alert('" + message + "');";
            str = str + "location.href('" + UrlToGoAfferMessage + "');";
            return str;
        }

        public static string testxxx()
        {
            string str = "test();";
            return str;
        }

        public static void PreparedConfirmButton(Button btn, String strConfirm)
        {
            btn.Attributes.Add("onclick", "return confirm('" + strConfirm + "');");
        }

        public static void PreparedConfirmButton(LinkButton btn, String strConfirm)
        {
            btn.Attributes.Add("onclick", "return confirm('" + strConfirm + "');");
        }

        public static void PopupButton(Button btn, string path, string w, string h)
        {
            btn.Attributes.Add("onclick", "OpenPopup('" + path + "','" + w + "','" + h + "');");
        }

        public static void CloseWindow(Page Page)
        {
            string str = "<script language=javascript>window.close();";
            str = str + "</script>";
            Page.RegisterClientScriptBlock("1", str);
        }
    }
}